"""
URL configuration for maoyan_system project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from user import views as user_views
from rest_framework_simplejwt.views import TokenRefreshView
from movie import views as movie_views
from system import views as system_views

urlpatterns = [
    path('admin/', admin.site.urls),
    # 用户认证相关
    path('api/login/', user_views.login),
    path('api/register/', user_views.register),
    path('api/logout/', user_views.logout),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    # 用户管理相关
    path('api/users/', user_views.get_users),
    path('api/user/<int:user_id>/', user_views.get_user_detail, name='user_detail'),
    path('api/user/<int:user_id>/update/', user_views.update_user, name='update_user'),
    path('api/user/<int:user_id>/toggle/', user_views.toggle_user_status, name='toggle_user_status'),
    path('api/user/<int:user_id>/delete/', user_views.delete_user, name='delete_user'),
    path('api/user/detail/', user_views.get_current_user_detail, name='current_user_detail'),
    # 角色管理
    path('api/roles/', user_views.get_roles),
    path('api/role/create/', user_views.create_role, name='create_role'),
    path('api/role/<int:role_id>/', user_views.get_role_detail, name='role_detail'),
    path('api/role/<int:role_id>/update/', user_views.update_role, name='update_role'),
    path('api/role/<int:role_id>/delete/', user_views.delete_role, name='delete_role'),
    # 电影相关API
    path('api/movies/', movie_views.get_movies),
    path('api/movies/stats/', movie_views.get_movie_stats),
    path('api/movies/fetch/', movie_views.fetch_movies_api),
    # 电影爬虫相关API
    path('api/movies/crawler/start/', movie_views.start_crawler),
    path('api/movies/crawler/stop/', movie_views.stop_crawler),
    path('api/movies/crawler/status/', movie_views.get_crawler_status),
    # 数据清洗相关API
    path('api/movies/clean/start/', movie_views.start_clean),
    path('api/movies/clean/reset/', movie_views.reset_clean),
    path('api/movies/clean/status/', movie_views.get_clean_status),
    path('api/movies/cleaned/', movie_views.get_cleaned_movies),
    # 系统设置相关API
    path('api/system/settings/', system_views.get_settings, name='get_settings'),
    path('api/system/settings/update/', system_views.update_settings, name='update_settings'),
]
